// pages/myself/integral/IntegralRules.js
var Zan = require('../../../dist/index.js');
let network = null;
let utils = null;
let api = null;
const app = getApp();

Page(Object.assign({}, Zan.TopTips, Zan.Toast,{

  /**
   * 页面的初始数据
   */
  data: {
    bindPhone: 0,
    perfectInfo: 0,
    sign: 0,
    saleRules:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    network = new app.NetWorkUtils();
    utils = new app.Utils();
    api = new app.Api();

    this.onPullDownRefresh();

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.setData({
      saleRules: []
    })
    wx.stopPullDownRefresh();
    network._post_json(this, api.integralRule, {}, success);
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
  
  // }
}))

var success = function(that,res){
  if (res.data.data) {
    that.setData({
      bindPhone: res.data.data.bindPhone,
      perfectInfo: res.data.data.perfectInfo,
      sign: res.data.data.sign,
      saleRules: that.data.saleRules.concat(res.data.data.saleRules),
    })

  }
}